package service;

import org.hibernate.Session;

import util.HibernateUtil;

import com.onlion.shop.domain.Cat;

public class AnnotationDomainManager {

	public static void main(String[] args) {
		AnnotationDomainManager mgr = new AnnotationDomainManager();
		// mgr.addCat("nana",(long)1);
		// mgr.addGirle("Lisha");
//		mgr.createGirlAndCat("girle2", "cat2");
		
		mgr.addCat("cat",33L);
		HibernateUtil.getSessionFactory().close();
	}


	private Long addCat(String name, Long girleId) {
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		session.beginTransaction();
		Cat cat = new Cat();
		cat.setName(name);
		cat.setGirlId(girleId);
		session.save(cat);
		session.getTransaction().commit();
		return cat.getId();
	}

}
